Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage/fs: change order of precedence for URL expansion #322

Merged
merged 4 commits into from
Jul 26, 2021

Conversation

sonmezonur
Copy link
Member

  • Glob(*) expansion must have precedence over directory expansion.

If the source URL is both glob and directory, s5cmd only copies objects in the directory. Example setup:

testdir
|-- abc*
|   |-- file1.txt
|   `-- file2.txt
`-- abcd
    |-- file1.txt
    `-- file2.txt
❯ s5cmd cp 'testdir/abc*' s3://bigtmp/prefix/
cp testdir/abc*/file2.txt s3://bigtmp/prefix/abc*/file2.txt
cp testdir/abc*/file1.txt s3://bigtmp/prefix/abc*/file1.txt

URL expansion for fs.List() is working like following:

1) if given source URL is a directory, it only walks the directory.
2) if given source URL has glob, it expands glob.
3) if given source is not glob or directory, it sends stat call to single file.

Since abc* is a directory, currently s5cmd does not try to expand glob. I think we should change the order of precedence for dir/glob expansion.

I added tests for both cp/rm commands.

* Glob(*) expansion must have precedence over directory expansion.
@sonmezonur sonmezonur requested a review from a team as a code owner July 13, 2021 15:24
@sonmezonur sonmezonur requested review from aykutfarsak and ilkinulas and removed request for a team July 13, 2021 15:24
@sonmezonur sonmezonur merged commit 4130a7e into master Jul 26, 2021
@sonmezonur sonmezonur deleted the fs_list_glob branch July 26, 2021 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants